﻿using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.SignalR;
using VOL.Core.Extensions;
using VOL.WebApi.CustomeMiddleWare;

namespace VOL.WebApi.Controllers.Hubs
{
    [Route("api/[controller]")]
    [TypeFilter(typeof(IpRestrictionFilterAttribute))]
    [ApiExplorerSettings(GroupName = "v3")]
    public class StatusMessageController : Controller
    {
        private readonly IHubContext<ToolStatusHub> _hubContext;
        private readonly IHubContext<WorkOrderStatusHub> _hubContext1;
        public StatusMessageController(IHubContext<ToolStatusHub> hubContext, IHubContext<WorkOrderStatusHub> hubContext1)
        {
            _hubContext = hubContext;
            _hubContext1 = hubContext1;
        }

        [HttpPost("toolstatus")]
        public IActionResult ToolStatus(string new_status, string id)
        {
            _hubContext.Clients.All.SendAsync("SendMessage", new_status + "&" + id);
            return Ok();
        }

        [HttpPost("workorderstatus")]
        public IActionResult WorkOrderStatus(int param)
        {

            return Content("");
        }

        [HttpPost("workordershangliao")]
        public IActionResult WorkOrderShangLiao(string param)
        {
            _hubContext1.Clients.All.SendAsync("ShangLiao", param);
            return Content("");
        }
    }
}
